<?php
/**
 * tpshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.tp-shop.cn
 * ----------------------------------------------------------------------------
 * Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
 * ============================================================================
 * $Author: 当燃   2016-05-10
 */ 
namespace Mobile\Controller;
use Home\Logic\UsersLogic;

class CouponController extends MobileBaseController {
	
    public $user_id = 0;
	
	public function _initialize()
    {
        parent::_initialize();
        if (session('?user')) {
            $user = session('user');
            $this->user_id = $user['user_id'];
        }
    }
    public function index(){  
    		$cateid = I('get.cateid',0); // 当前分类id
			$logic = new UsersLogic();
			$data = $logic->get_couponlist('5',$cateid,$this->user_id);
			$coupon_list = $data['result'];
			$this->assign('coupon_list',$coupon_list);
			$this->assign('page',$data['show']);
			$this->assign('active','coupon');
			$this->display();
    }
	
	public function save_coupon()
    {
        $id = I('get.id');
        //检查是否有积分，余额支付
        $logic = new UsersLogic();
		$result = $logic->coupon_save($this->user_id,$id);
        exit(json_encode($result));
    }
	

}